/*
 * Copyright 2012 Walter Lütgenau.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package offset.nodes.client.editor;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author
 * Walter
 * Lütgenau
 */
public class ImageTest {

    public static class ImageComponent extends JPanel {

        Image image;

        public ImageComponent(Image image) {
            this.image = image;
        }

        @Override
        public void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters            
        }
    }

    public static void main(String[] arguments) throws Exception {
        JLabel label = new JLabel();
        label.setForeground(Color.RED);
        label.setText("Hello world");

        JFrame t1 = new JFrame();
        t1.add(label);
        t1.pack();
        t1.setVisible(true);

        Image image = label.createImage((int) label.getSize().getWidth(), (int) label.getSize().getHeight());
        Graphics g = image.getGraphics();
        label.paint(g);
        Image image2 = ImageIO.read(new File("C:/Dokumente und Einstellungen/Walter Lütgenau/Eigene Dateien/icons/true.png"));
        JLabel imageLabel = new JLabel(new ImageIcon(image));
        JFrame t2 = new JFrame();
        t2.add(imageLabel);
        t2.pack();
        t2.setVisible(true);
    }
}
